package net.xdclass.websocket.listener;

import org.springframework.context.ApplicationListener;
import org.springframework.messaging.simp.SimpMessageType;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.messaging.SessionConnectEvent;

/**
 * @description: 订阅事件监听器
 * @author: Yz
 * @create: 2020-06-30 15:44
 **/
@Component
public class ConnectEventListener implements ApplicationListener<SessionConnectEvent> {


    @Override
    public void onApplicationEvent(SessionConnectEvent event) {
        StompHeaderAccessor headerAccessor = StompHeaderAccessor.wrap(event.getMessage());
        SimpMessageType messageType = headerAccessor.getCommand().getMessageType();
        System.out.println("【ConnectEventListener监听器事件 类型】："+messageType);
    }
}
